package com.example.zhaoyulu.yunzhiapp;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.network.getRetrofitService;
import com.example.network.javaBeans.Book;
import com.example.network.javaBeans.yzjyinfo;
import com.example.zhaoyulu.yunzhiapp.zylUtils.staticInfo;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class LoginActivity extends zylBaseActivity {

    EditText login_getId;
    EditText login_getPassWord;
    Button login_getIntoApp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        init();

        login_getIntoApp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                getRetrofitService.getService().getyzjyinfo().enqueue(new Callback<List<yzjyinfo>>() {
                    @Override
                    public void onResponse(Call<List<yzjyinfo>> call, Response<List<yzjyinfo>> response) {
                        staticInfo.yzjyinfoList=response.body();
                        if(staticInfo.yzjyinfoList==null) return;
                        Intent intent=new Intent();
                        intent.setClass(LoginActivity.this,MainActivity.class);
                        startActivity(intent);
                    }

                    @Override
                    public void onFailure(Call<List<yzjyinfo>> call, Throwable t) {

                    }
                });
            }
        });
    }

    public void init(){
        login_getId=findViewById(R.id.login_getId);
        login_getPassWord=findViewById(R.id.login_getPassWord);
        login_getIntoApp=findViewById(R.id.login_getIntoApp);
    }
}
